#pragma once
#include <string>
#include "msgdef.h"
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include "base/base.h"
#include "serial_port.h"
#include "duilib/UIlib.h"
#include "tcp_client.h"
#include "lua_wraper.h"
#include "global.h"
#include <fstream>
#include "udp_libevent.h"
#include <istream>
#include "websocket_client.h"
#include "lua_bind.h"

class WebsocketClientForm :
	public ui::ChildBox,
	LuaBindInterface
{
public:
	WebsocketClientForm(ui::Window* hwnd, string url, WebsocketClient* p);
	~WebsocketClientForm();
	virtual void Init() override;
	LuaDelegate* LuaVM();
	void ShowDataInEdit(const char*);
	void OnConnected(WebsocketClient*);
	void OnDisConnected(WebsocketClient*, WebsocketClient::CloseReason);
	void OnReadHandler(WebsocketClient*, std::string);
private:
	ui::Label* m_label_1;
	ui::RichEdit* m_rich_edit_1;
	ui::RichEdit* m_rich_edit_2;
	ui::RichEdit* m_websocket_send_edit;
	ui::Button* m_btn_send_data;
	ui::Button* m_btn_save_lua;
	ui::Button* m_btn_close_form;
	ui::CheckBox* m_check_box_1;
	ui::CheckBox* m_check_box_2;
	ui::CheckBox* m_check_box_3;
	ui::CheckBox* m_check_box_4;


	WebsocketClient* mWebsocketClient;
	std::fstream mLuaFileRead;
	std::ofstream mLuaFileEdit;


	LuaDelegate* mLua;
	std::string mLuaScript;
	std::ifstream mLuaFile;
};

